﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
using metroCIS.Library;
using Windows.Storage;

namespace metroCIS.Test
{
    [TestClass]
    public class CisManagerTest
    {
        private async Task<CisManager> Login()
        {
            var fileName = "LoginData.txt";
            var path = Windows.ApplicationModel.Package.Current.InstalledLocation;
            var content = await FileIO.ReadTextAsync(await path.GetFileAsync(fileName));

            var parts = content.Split(';');
            var username = parts[0];
            var pwd = parts[1];

            var manager = new CisManager(username, pwd);
            var res = await manager.Login();
            return res ? manager : null;
        }



        [TestMethod]
        public async Task LoginIntoCis()
        {
            var manager = await Login();
            Assert.IsNotNull(manager);
        }

        [TestMethod]
        public async Task GetLVPlan()
        {
            var manager = await Login();
            var allEntries = await manager.GetLVPlan();
            Assert.IsNotNull(allEntries);
            Assert.IsTrue(allEntries.Any());
        }

        [TestMethod]
        public async Task GetRSSFeed()
        {
            var manager = await Login();
            var feed = await manager.GetRssFeed();
            Assert.IsNotNull(feed);
            Assert.IsTrue(feed.Count > 0);
        }

        [TestMethod]
        public async Task GetLVInfoList()
        {
            var manager = await Login();
            var list = await manager.GetLvInfo();
            Assert.IsTrue(list.Count > 0);
        }

        [TestMethod]
        public async Task GetRoomList()
        {
            var manager = await Login();
            var list = await manager.GetRooms();
            //Assert.IsTrue(list.Count > 0);
        }

        [TestMethod]
        public async Task GetAllGrades()
        {
            var manager = await Login();
            var allEntries = await manager.GetGrades();
            Assert.IsNotNull(allEntries);
        }

        //[TestMethod]
        //public async Task GetAllFreeRooms()
        //{
        //    var manager = await Login();
        //    foreach (RoomType roomType in Enum.GetValues(typeof(RoomType)))
        //    {
        //        var allEntries = await manager.GetFreeRooms(roomType);
        //        Assert.IsNotNull(allEntries);
        //    }
        //}
    }
}
